// 进度条
import 'nprogress/nprogress.css'
import { start, done, configure } from 'nprogress'
configure({
    trickleSpeed: 20,
    showSpinner: false
})
const About = getPageComponent(() => import('../views/About/index.vue'))
const Blog = getPageComponent(() => import('../views/Blog/index.vue'))
const BlogDetail = getPageComponent(() => import('../views/Blog/Detail.vue'))
const Project = getPageComponent(() => import('../views/Project/index.vue'))
const Message = getPageComponent(() => import('../views/Message/index.vue'))
const Not = getPageComponent(() => import('../views/404/index.vue'))
// const Home = () => import('../views/Home/index.vue')
const Home = getPageComponent(() => import('../views/Home/index.vue'))
function getPageComponent(pageCompResolve) {
    return async () => {
        start()
        if (process.env.NODE_ENV === 'development') {
            delay(2000)
        }
        const comp = await pageCompResolve()
        done()
        return comp
    }
}


function delay(delay = 500) {
    return new Promise((resolve, reject) => {
        setTimeout(() => resolve, delay)
    })
}

export default [
    // {
    //   path: '/',
    //   redirect:'/home',
    //   component:Home
    // },
    { name: 'home', path: '/', component: Home, meta: { title: '首页' } },
    { name: 'about', path: '/about', component: About, meta: { title: '关于我' } },
    { name: 'blog', path: '/blog', component: Blog, meta: { title: '文章' } },
    { name: "categoryBlog", path: "/article/cate/:categoryId", component: Blog, meta: { title: '分类' } },
    { name: "blogDetail", path: "/article/:id", component: BlogDetail, meta: { title: '文章详情' } },
    { name: 'project', path: '/project', component: Project, meta: { title: '项目&效果' } },
    { name: 'message', path: '/message', component: Message, meta: { title: '404' } },
    { name: '404', path: '/*', component: Not }
]